package net.zjitc.action;

import net.zjitc.service.UserService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2017/2/27.
 */
@Controller
@Scope("prototype")
public class UserAction {
    /*登录界面
    * */
private String message;
private  String username;
private String password;
@Resource
 private UserService userService;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String loginUI(){
        return "loginUI";
    }
//    登录
    public String login(){
//     如果有用户的话。返回登录成功，否则返回失败

        User user=userService.findByUsernamePassword(username,password);
        if (user!=null){
            message="登陆成功";
            return "loginSuccess";
        }
        message="用户名或密码错误";
        return "loginFail";
    }
}
